/**
 * 

 */
package edu.vt.ece.rt.dstm.contention;

import edu.vt.ece.rt.dstm.Context;

/**
 * Resolve Contention Using Transaction Number, Higher the transaction Number, Lower the priority
 * @author Sudhanshu
 *
 */
public class Priority extends AbstractContentionPolicy {

	/* (non-Javadoc)
	 * @see edu.vt.ece.rt.dstm.contention.AbstractContentionPolicy#resolve(edu.vt.ece.rt.dstm.Context, edu.vt.ece.rt.dstm.Context)
	 */
	@Override
	public int resolve(Context context1, Context context2) {
		if(context1.getContextId() > context2.getContextId())
			return +1;						//Priority queue will arrange as head least priority transaction first, so reversed
		else 
			return -1;
	}

	@Override
	public void init(Context context) {}

	@Override
	public void open(Context context) {}

}
